// pages/detail-video/detail-video.js

import {
  getMvUrl, getMvInfo,getMvRelateVideo
} from "../../services/video"

Page({

  /**
   * 页面的初始数据
   */
  data: {
    id: '',
    mvUrl: '',
    danmuList: [{
      text: '第 1s 出现的弹幕',
      color: '#ff0000',
      time: 1
    }, {
      text: '第 3s 出现的弹幕',
      color: '#ff00ff',
      time: 3
    }],
    mvInfo:{},
    mvRelateVideo:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    // console.log(options);
    // 1，获取id
    this.setData({
      id: options.id
    })
    // 2,根据id 发送网络请求
    this.fectchMVUrl()
    this.fectchMVDetail()
    this.fectchMvRelateVideo()
  },
  async fectchMVUrl() {
    const res = await getMvUrl(this.data.id)
    this.setData({
      mvUrl: res.data.url
    })
  },
  async fectchMVDetail() {
    const res = await getMvInfo(this.data.id)
    this.setData({
      mvInfo: res.data
    })
  },
 
  async fectchMvRelateVideo() {
    const res = await getMvRelateVideo(this.data.id)
    this.setData({
      mvRelateVideo: res.data
    })
  },
 
 

 
})